using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter28
{
	/// <summary>
	/// Example06: Three Resistors in Parallel
	/// Three resistors are connected in parallel as shown 
	/// in Figure 28.11a. A potential difference of 18.0 V is 
	/// maintained between points a and b.
	/// (A)	
	/// Find the current in each resistor.
	/// (B)	
	/// Calculate the power delivered to each resistor and 
	/// the total power delivered to the combination of resistors.
	/// (C)
	/// Calculate the equivalent resistance of the circuit.
	/// </summary>
	public class Example06
	{
		public Example06()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricPotentialDifference V
				= new L.ElectricPotentialDifference();
			V.V = 18.0;
			L.Resistance R1 = new L.Resistance();
			R1.Ohm = 3.0;
			L.Resistance R2 = new L.Resistance();
			R2.Ohm = 6.0;
			L.Resistance R3 = new L.Resistance();
			R3.Ohm = 9.0;

			//(A)
			L.ElectricCurrent I1 = new L.ElectricCurrent(R1,V);
			L.ElectricCurrent I2 = new L.ElectricCurrent(R2,V);
			L.ElectricCurrent I3 = new L.ElectricCurrent(R3,V);
			result+=Convert.ToString(I1.A)+"\r\n";
			result+=Convert.ToString(I2.A)+"\r\n";
			result+=Convert.ToString(I3.A)+"\r\n";

			//(B)
			L.ElectricPower P1 = new L.ElectricPower(R1,I1);
			L.ElectricPower P2 = new L.ElectricPower(R2,I2);
			L.ElectricPower P3 = new L.ElectricPower(R3,I3);
			result+=Convert.ToString(P1.W)+"\r\n";
			result+=Convert.ToString(P2.W)+"\r\n";
			result+=Convert.ToString(P3.W)+"\r\n";

			//(C)
			L.Resistance R4 = L.Resistance.Parallel(R1,R2);
			L.Resistance Rsum = L.Resistance.Parallel(R3,R4);
		
			result+=Convert.ToString(Rsum.Ohm)+"\r\n"; 
		}
	}
}
